/**
 * 
 */
package com.pinapel.aixml.models.xml.errorHandlers;

import java.util.Iterator;
import java.util.List;

import com.pinapel.aixml.models.xml.NodeID;
import com.pinapel.aixml.models.xml.dom.sch.SvrlDomModel;
import com.pinapel.aixml.tools.log.EnumMessageType;
import com.pinapel.aixml.tools.log.Logger;

/**
 * @author Yoli
 *
 */
public class SchematronErrorReporter extends FullTransformErrorReporter {
	private SvrlDomModel mReport;
	
	/**
	 * @param baseMessage
	 */
	public SchematronErrorReporter(String baseMessage) {
		super(baseMessage);
	}
	
	public void printSvrlFailedMessages() {
		if(mReport==null) {
			Logger.addMessage(EnumMessageType.DEBUG_ERROR, this.getClass().getName() + ": the SVRL report has not been initialized.");
		} else {
			List<String> fAsserts;
			fAsserts = mReport.getFailedAsserts();
			Iterator<String> iter = fAsserts.iterator();
			if(iter.hasNext()) {
				this.setError();
			}
			while(iter.hasNext()) {
				Logger.addMessage(EnumMessageType.ERROR, this.getBaseMessage()+ iter.next());
			}
		}
	}
	
	public void setSVRLReport(SvrlDomModel report) {
		mReport = report;
	}
	
	public String getSVRLReportAsString() {
//		return mReport.getDomNode().toString();
		int[] index = {0};
		NodeID id = new NodeID(index);
		return mReport.getNode(id).getTextVersion();
	}
	

}
